package com.alison.customeds;

import com.zaxxer.hikari.HikariDataSource;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.ApplicationArguments;
import org.springframework.boot.ApplicationRunner;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.util.Assert;

import javax.sql.DataSource;

/**
 * Hello world!
 */

@SpringBootApplication
public class App implements ApplicationRunner {

    @Autowired
    JdbcTemplate jdbcTemplate;

    public static void main(String[] args) {
        SpringApplication.run(App.class);
    }

    @Override
    public void run(ApplicationArguments args) throws Exception {
        Assert.notNull(jdbcTemplate);
        DataSource dataSource = jdbcTemplate.getDataSource();
        System.out.println("dataSource==" + dataSource);
        HikariDataSource hikariDataSource = (HikariDataSource) dataSource;
        Assert.state("jdbc:mysql://localhost:3306/test?useUnicode=true&characterEncoding=utf8".equalsIgnoreCase(hikariDataSource.getJdbcUrl()));
    }
}
